program WtMenu;

uses
  FastMM4,
  Forms,
  Windows,
  MainUnit in 'MainUnit.pas' {frmMenuMain},
  PublicUnit in 'PublicUnit.pas',
  FunctionUnit in '..\..\FunctionUnit.pas',
  ConstUnit in '..\..\ConstUnit.pas',
  TcpFileClient in '..\..\TcpFileClient.pas',
  ProtocolUnit in '..\..\ProtocolUnit.pas',
  TcpIndexUnit in '..\..\TcpIndexUnit.pas',
  VDUnit in '..\..\VDUnit.pas',
  SyncNodeUtil in '..\..\SyncNodeUtil.pas';

{$R *.res}
{$R app.res}

var
  hMutex, hUpdateMutex : THandle;
  Ret: DWORD;
begin
  hUpdateMutex := CreateMutex(nil, False, PChar(UpdateMutex));
  Ret := GetLastError;
//  if Ret  = ERROR_ALREADY_EXISTS then
  if hUpdateMutex = 0 then
  begin
    CloseHandle(hUpdateMutex);
    Exit;
  end;
    
  hMutex := CreateMutex(nil, False, WtMenuMutex);
  if GetLastError = ERROR_ALREADY_EXISTS then
  begin
    CloseHandle(hMutex);
    Exit;
  end;
//  Ret := GetLastError;
//  if Ret <> ERROR_ALREADY_EXISTS then
//  begin

    Application.Initialize;
    Application.Title := 'Game Menu';
  Application.CreateForm(TfrmMenuMain, frmMenuMain);
  Application.Run;
    CloseHandle(hMutex);
//  end
//  else
//    ReleaseMutex(hMutex);

end.
